﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bussiness;

namespace Bussiness.Service
{
   public class ImageService
    {
       public List<Images> loadImage(string id, string path)
       {
           //string path = Server.MapPath("/Views/BackEnd/images/small");
           string[] files = System.IO.Directory.GetFiles(path);
           List<string> listFile = new List<string>();
           for (int i = 0; i < files.Length; i++)
           {

               if (System.IO.Path.GetFileName(files[i]).Split('_')[0] == id)
               {
                   listFile.Add(files[i]);
               }
           }

           List<Images> data = new List<Images>(listFile.Count);
           foreach (string fileName in listFile)
           {
               System.IO.FileInfo fi = new System.IO.FileInfo(fileName);
               Images image = new Images();
               image.Name = fi.Name;
               image.Lastmod = fi.LastAccessTime;
               image.Size = fi.Length;
               image.Url = "/Addmin/BackEnd/images/small/" + fi.Name;
               image.UrlLager = "/Addmin/BackEnd/images/large/" + fi.Name;
               data.Add(image);
           }
           return data;
       }


    }
}
